package Demo_D;

public class Deom_D {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
           while(true) {
               System.out.println("hello thread");
               try {
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                   throw new RuntimeException(e);
               }
           }
        },"我的线程");

        //启动线程
        t.start();

        //主线程（main）等待子线程（t）
        t.join();

        System.out.println("主线程结束");
    }
}
